﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Abp.Application.Services.Dto;
using Abp.Authorization.Roles;
using Abp.AutoMapper;
using Abp.Domain.Entities;
using KelonProud.Administration.Domain.Authorization;
using System.Linq;

namespace KelonProud.Administration.Dtos
{
    [AutoMap(typeof(Role))]
    public  class RoleInputDto : EntityDto
    {
        [Required]
        [StringLength(20, MinimumLength = 2, ErrorMessage = "角色编号长度必须在2-20个字符之间")]
        public string Name { get; set; }

        [Required]
        [StringLength(20, MinimumLength = 2, ErrorMessage = "角色名称长度必须在4-20个字符之间")]
        public string DisplayName { get; set; }

        [StringLength(Role.MaxDescriptionLength)]
        public string Description { get; set; }

        public  DateTime CreationTime { get; set; }

        public  string[] NavigationIds { get; set; }

        public virtual int? TenantId { get; set; }

        public IEnumerable<NavigationOutputDto> RoleDtos { get; set; }

        public bool RoleIsInNav(NavigationOutputDto navigationOutput)
        {
            return NavigationIds?.Contains(navigationOutput.Id.ToString()) ?? false;
        }
    }

    [AutoMap(typeof(Role))]
    public class RoleOutPutDto: RoleInputDto
    {
        public string NormalizedName { get; set; }

        public bool IsStatic { get; set; }

        public List<string> Permissions { get; set; }
    }
}
